﻿package mortal.game.view.guildNew.member
{
    import com.mui.controls.*;
    import com.mui.display.*;
    import com.mui.events.*;
    import extend.language.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.resource.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.button.*;
    import mortal.game.view.guildNew.data.*;
    import mortal.mvc.core.*;

    public class GuildNewMemTitleSp extends GSprite
    {
        protected var _bg:ScaleBitmap;
        protected var _pos:GTextFiled;
        protected var _memberName:GTextFiled;
        protected var _pow:GTextFiled;
        protected var _levelJob:GTextFiled;
        protected var _todayCon:GTextFiled;
        protected var _totalCon:GTextFiled;
        protected var _active:GTextFiled;
        public var _txtSate:GTextFiled;
        public var _btnSortByPosition:SortButton;
        public var _btnSortByFightpower:SortButton;
        public var _btnSortByLevel:SortButton;
        public var _btnSortByTodayContribution:SortButton;
        public var _btnSortByTotalContribution:SortButton;
        public var _btnSortByActive:SortButton;
        public var _btnSortByOnLine:SortButton;
        public var sortFunction:Function;

        public function GuildNewMemTitleSp()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.bg(0, 0, 749, 23, this, ImagesConst.RegionTitleBg);
            this._pos = UIFactory.gTextField("" + Language.getString(71525), 100, 2, 50, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._memberName = UIFactory.gTextField("" + Language.getString(71526), 178, 2, 60, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._pow = UIFactory.gTextField("" + Language.getString(71527), 297, 2, 50, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._levelJob = UIFactory.gTextField("" + Language.getString(71528), 395, 2, 60, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._todayCon = UIFactory.gTextField("" + Language.getString(71529), 473, 2, 60, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._totalCon = UIFactory.gTextField("" + Language.getString(71530), 545, 2, 50, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._active = UIFactory.gTextField("" + Language.getString(71531), 610, 2, 50, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._txtSate = UIFactory.gTextField("" + Language.getString(71532), 688, 2, 50, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._btnSortByPosition = UIFactory.sortButton(127, 6, this);
            this._btnSortByPosition.configEventListener(SortEvent.DESCENDING, this.onSortChange);
            this._btnSortByPosition.configEventListener(SortEvent.ASCENDING, this.onSortChange);
            this._btnSortByFightpower = UIFactory.sortButton(340, 6, this);
            this._btnSortByFightpower.configEventListener(SortEvent.DESCENDING, this.onSortChange);
            this._btnSortByFightpower.configEventListener(SortEvent.ASCENDING, this.onSortChange);
            this._btnSortByLevel = UIFactory.sortButton(448, 6, this);
            this._btnSortByLevel.configEventListener(SortEvent.DESCENDING, this.onSortChange);
            this._btnSortByLevel.configEventListener(SortEvent.ASCENDING, this.onSortChange);
            this._btnSortByTodayContribution = UIFactory.sortButton(525, 6, this);
            this._btnSortByTodayContribution.configEventListener(SortEvent.DESCENDING, this.onSortChange);
            this._btnSortByTodayContribution.configEventListener(SortEvent.ASCENDING, this.onSortChange);
            this._btnSortByTotalContribution = UIFactory.sortButton(583, 6, this);
            this._btnSortByTotalContribution.configEventListener(SortEvent.DESCENDING, this.onSortChange);
            this._btnSortByTotalContribution.configEventListener(SortEvent.ASCENDING, this.onSortChange);
            this._btnSortByActive = UIFactory.sortButton(651, 6, this);
            this._btnSortByActive.configEventListener(SortEvent.DESCENDING, this.onSortChange);
            this._btnSortByActive.configEventListener(SortEvent.ASCENDING, this.onSortChange);
            this._btnSortByOnLine = UIFactory.sortButton(716, 6, this);
            this._btnSortByOnLine.configEventListener(SortEvent.DESCENDING, this.onSortChange);
            this._btnSortByOnLine.configEventListener(SortEvent.ASCENDING, this.onSortChange);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this.sortFunction = null;
            this._bg = null;
            this._pos = null;
            this._memberName = null;
            this._pow = null;
            this._levelJob = null;
            this._todayCon = null;
            this._totalCon = null;
            this._active = null;
            this._txtSate = null;
            this._btnSortByPosition = null;
            this._btnSortByFightpower = null;
            this._btnSortByLevel = null;
            this._btnSortByTodayContribution = null;
            this._btnSortByTotalContribution = null;
            this._btnSortByActive = null;
            this._btnSortByOnLine = null;
            return;
        }// end function

        private function onSortChange(event:SortEvent) : void
        {
            switch(event.target)
            {
                case this._btnSortByPosition:
                {
                    this.sortFunction = GuildUtil.constructMemberListSortFunc("position", event.type);
                    break;
                }
                case this._btnSortByLevel:
                {
                    this.sortFunction = GuildUtil.constructMemberListSortFunc("level", event.type, true);
                    break;
                }
                case this._btnSortByFightpower:
                {
                    this.sortFunction = GuildUtil.constructMemberListSortFunc("combat", event.type, true);
                    break;
                }
                case this._btnSortByTodayContribution:
                {
                    this.sortFunction = GuildUtil.constructMemberListSortFunc("contributionDay", event.type);
                    break;
                }
                case this._btnSortByTotalContribution:
                {
                    this.sortFunction = GuildUtil.constructMemberListSortFunc("totalContribution", event.type);
                    break;
                }
                case this._btnSortByActive:
                {
                    this.sortFunction = GuildUtil.constructMemberListSortFunc("activity", event.type);
                    break;
                }
                case this._btnSortByOnLine:
                {
                    this.sortFunction = GuildUtil.constructMemberListSortFunc("online", event.type, true);
                    break;
                }
                default:
                {
                    break;
                }
            }
            Dispatcher.dispatchEvent(new DataEvent(GuildNewLocalEvent.GuildNewMemberUpdate));
            return;
        }// end function

    }
}
